package com.jingdun.sport.authority

import com.jingdun.sport.rp.RPCallback
import com.jingdun.sport.rp.RPResult
import com.losttemple.sql.language.dialects.DialectEnvironment
import com.losttemple.sql.language.operator.db
import com.losttemple.sql.language.operator.eq
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service
class RPCallbackImpl: RPCallback {
    @Autowired
    private lateinit var sql: DialectEnvironment

    override fun succeed(result: RPResult) {
        sql.run {
            db { Users(it) }
                    .where { id eq result.user }
                    .update {
                        it.authentic(true)
                    }()
        }
    }

    override fun failed(user: String) {
        TODO("Not yet implemented")
    }
}